﻿using System.Windows;
using jSLCore.Client.Presentation.Authorization;
using jSLCore.Client.Presentation.Authorization.Managment;
using jSLCore.Client.Presentation.BaseControl;
using jSLCore.Client.Presentation.BaseControl.DialogMessage;

namespace jSLApp.Client.Forms
{
    public partial class StartPage : DataControl
    {
        public StartPage()
        {
            InitializeComponent();
            jSecurity.SecurityChanged += (sender, args) =>
                                             {
                                                 if (!jSecurity.IsAuthorized) txt.Text = "";
                                             };
        }


        private void ShowFirstUser()
        {
            this.DoWorkOnSingle("Who is first user calculating",context => context.GetFirstUserQuery(),(b, user) =>
                                                                                                           {
                                                                                                               if(!b)InfoBox.ShowDialog(user.Login.Trim());
                                                                                                           });
        }

        private void showFirstUser_Clicked(object sender, RoutedEventArgs e)
        {
            ShowFirstUser();
        }

        private void goto_Security(object sender, RoutedEventArgs e)
        {
            NavigateTo(new ManagmentPanel());
        }
    }
}
